package thermologic.core;

/**
 * An adapter represents the layer between
 * hardware and the application 
 * 
 * @author Mauricio Rivadeneira
 */
public interface Adapter
{    
    /**
     * stablishes the connection between 
     * the PC and the adapter
     * 
     * @throws thermologic.core.AdapterException
     */
    public void connect() throws AdapterException;
    
    
    /**
     * Ends the the connection between PC and adapter
     * 
     * @throws thermologic.core.AdapterException
     */
    public void disconnect() throws AdapterException;
    
    
    /**
     * Checks if the adapter is accesible
     * 
     * @return true if adapter is accesible and working
     */
    public void check() throws AdapterException;
    
    /**
     * Ask to adapter if is bussy
     * 
     * @return
     */
    public boolean isBussy();
        
    /**
     * Performs a device search
     */
    public void searchDevices();
    
    /**
     * Connects and search devices
     */
    public void connectAndSearch();
    
    /**
     * @return An inmutable array of devices previously searched
     */    
    public Device[] getDevices();
    
    /**
     * Set up the device 
     */
    public void setupDevice(Device d);
    
    /**
     * Connects to adapter and setup the device
     * 
     * @param device
     */
    public void connectAndSetup(Device device);    
    
    /**
     * Adds a listener 
     * 
     * @param listener
     */
    public void addListener(AdapterListener listener);
}
